Welcome Guest | Sign in | Register
.NET Programming Concepts - DotNet Programming Interview Questions and Answers | LucentBlackBoard | LucentBlackBoard.com

Home > Technical Interviews > Computer Science & Engineering > DotNet Programming > .NET Programming Concepts Questions and Answers

6. What is the difference between constants and read-only variables that are used in programs?

Constants perform the same tasks as read-only variables with some differences. The differences between constants and read-only are

Constants:
1. Constants are dealt with at compile-time.
2. Constants supports value-type variables.
3. Constants should be used when it is very unlikely that the value will ever change.

Read-only:
1. Read-only variables are evaluated at runtime.
2. Read-only variables can hold reference type variables.
3. Read-only variables should be used when run-time calculation is required.

7. Differentiate between the while and for loop in C#.

The while and for loops are used to execute those units of code that need to be repeatedly executed, unless the result of the specified condition evaluates to false. The only difference between the two is in their syntax. The for loop is distinguished by setting an explicit loop variable.

8. What is an identifier?

Identifiers are northing but names given to various entities uniquely identified in a program. The name of identifiers must differ in spelling or casing. For example, MyProg and myProg are two different identifiers. Programming languages, such as C# and Visual Basic, strictly restrict the programmers from using any keyword as identifiers. Programmers cannot develop a class whose name is public, because, public is a keyword used to specify the accessibility of data in programs.

9. What does a break statement do in the switch statement?

The switch statement is a selection control statement that is used to handle multiple choices and transfer control to the case statements within its body. The following code snippet shows an example of the use of theswitch statement in C#:
switch(choice)
{
case 1:
console.WriteLine("First");
break;
case 2:
console.WriteLine("Second");
break;
default:
console.WriteLine("Wrong choice");
break;
}

In switch statements, the break statement is used at the end of a case statement. The break statement is mandatory in C# and it avoids the fall through of one case statement to another.

10. Explain keywords with example.

Keywords are those words that are reserved to be used for a specific task. These words cannot be used as identifiers. You cannot use a keyword to define the name of a variable or method. Keywords are used in programs to use the features of object-oriented programming.

For example, the abstract keyword is used to implement abstraction and the inherits keyword is used to implement inheritance by deriving subclasses in C# and Visual Basic, respectively.

The new keyword is universally used in C# and Visual Basic to implement encapsulation by creating objects.




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.